
        /*
 * To change this template, choose Tools | Templates
 * and open the template in the editor.
 */

package oscilloscope;

import java.io.IOException;
import java.util.regex.Matcher;
import java.util.regex.Pattern;

/**
 *
 * @author francispapineau
 */
public class SplitParseDigital {

    /*________________________________________________________________________________*/

    private static String REGEX1 = "[!|OnTweFoiSSEN]";
    static public int i = 0, count = 0, j = 0;
    static public String One = "", Two = "", Three = "", Four = "", Five = "", Six = "", Seven = "", Eight = "";
    static public double Num1 = 0.00, Num2 = 0.00, Num3 = 0.00, Num4 = 0.00, Num5 = 0.00, Num6 = 0.00, Num7 = 0.00, Num8 = 0.00;
    static public double choiceArrayDigital[];

   /*________________________________________________________________________________*/


    static public void splitVal(String Val) throws IOException{
        choiceArrayDigital = new double[9];
        count++;
        Pattern p = Pattern.compile(REGEX1);
        String[] items = p.split(Val);
        for(String s : items) {
            if (i == 5){
                One = items[5];
                Num1 = Double.parseDouble(One);
                choiceArrayDigital[0] = Num1;
            }
            else if (i == 9){
                Two = items[9];
                Num2 = Double.parseDouble(Two);
                choiceArrayDigital[0] = Num1;

            }
            else if (i == 13){
                Three = items[13];
                Num3 = Double.parseDouble(Three);
                choiceArrayDigital[0] = Num1;

            }
            else if (i == 17){
                Four = items[17];
                Num4 = Double.parseDouble(Four);
                choiceArrayDigital[0] = Num1;

            }
            else if (i == 21){
                Five = items[21];
                Num5 = Double.parseDouble(Five);
                choiceArrayDigital[0] = Num1;

            }
            else if (i == 25){
                Six = items[25];
                Num6 = Double.parseDouble(Six);
                choiceArrayDigital[0] = Num1;

            }
            else if (i == 29){
                Seven = items[29];
                Num7 = Double.parseDouble(Seven);
                choiceArrayDigital[0] = Num1;

            }
            else if (i == 33){
                Eight = items[33];
                Num8 = Double.parseDouble(Eight);
                choiceArrayDigital[0] = Num1;

            }
            i++;
        }
        i = 0;
    }

       /*________________________________________________________________________________*/

    public static boolean parsable(String val){

        Pattern p = Pattern.compile("(A)(|Ze:)(\\d+)(.)(\\d+)(|On:)(\\d+)(.)(\\d+)(|Tw:)(\\d+)(.)(\\d+)(|Th:)(\\d+)(.)(\\d+)"
                + "(|Fo:)(\\d+)(.)(\\d+)(|Fi:)(\\d+)(.)(\\d+)(|Si:)(\\d+)(.)(\\d+)(|Se:)(\\d+)(.)(\\d+)(|Ei:)(\\d+)(.)(\\d+)");
        Matcher m = p.matcher(val);

        if (m.find()){
            return true;
        }
        else{
            return false;
        }
    }
}
